var slider = document.querySelector('.slider');
var images = slider.querySelectorAll('img');
var currentIndex = 0;

function slideTo(index) {
    for (var i = 0; i < images.length; i++) {
        images[i].style.left = (i - index) * 100 + '%';
    }
}

function nextSlide() {
    currentIndex = (currentIndex + 1) % images.length;
    slideTo(currentIndex);
}

setInterval(nextSlide, 2000); // 每2秒切换到下一张图片
